<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: show_results2.tpl.php 1151 2008-06-24 15:07:32Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 

?>
<div id="joomleague">
<a name="jl_top" id="jl_top"></a>
<!-- Header with Project Name-->
<?php if ($showPlan_config['show_project_heading'] == "1" OR $overall_config['show_project_heading'] == "1") { ?>
<div class="componentheading" <?php if ($showPlan_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") echo 'style="float:left;"';?>><?php echo $htmlHelper->showTitle($joomleague, $overall_config['project_heading_type']); ?></div>
<!-- Druckfunktion -->
<?php if ($showPlan_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") {
$htmlHelper->PrintIcon( $row, $params, false, '' );
};?>
<!-- Druckfunktion Ende -->
<?php } ?>
<!-- Header END -->

<?php if ($showPlan_config['show_section_heading']==1) { ?>
<!-- Bereichs�berschrift z.B Tabelle, Tippabgabe usw. bei Bedarf mit Drucksymbol -->
<table width="100%" class="contentpaneopen">
	<tr>
		<td class="contentheading"><?php echo _JL_PLAN;?> <?php
		if (isset($division)) echo $division->name.' ';
		if ( $team_plan ) echo $teams[$team_plan]->name; ?>
    </td>
    <td align="right">
  		<a href="<?php 
              echo JL_COMPONENT_LINK_NOHTML
                . '&amp;func=ical'
                . '&amp;p=' . $joomleague->id;
              if ( $team_plan ) {
                echo '&amp;tid=' . $teams[$team_plan]->id;
              }  
              ?>">
        <img border="0" src="<?php 
              echo _JOOMLA_JL_LIVE_SITE 
                  . '/components/com_joomleague/frontend/default/images/'
                  . 'calendar32.png'; 
              ?>" alt="iCal export" title="iCal export"/>
      </a>
    </td>
	</tr>
</table>
<!-- Bereichs�berschrift Ende -->
<?php } ?>

<br />
<?php
	if (isset($overall_config['results_below'])&&$overall_config['results_below']==1) $showPlan_config['results_below']=1;
	$htmlHelper->resultsColspan($showPlan_config);
	$whatday=0;
	//print_r($rounds);
	foreach ($rounds AS $round) {
	  //echo $round->id."<br/>";
		$matches = $joomleague->getResultsRows( $round->matchcode, $divisionid, $showPlan_config, $tid ); 
		?>
		
		<table width="100%" class="contentpaneopen">
			<tr>
				<td class="contentheading">
				<?php
		      $htmlHelper->show_matchdays_title('', $round->id, $showPlan_config, 1);
				?>
				</td>
		  </tr>
		</table>
		<br />

		<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
		<?php
			$teamid = $team_plan;
			if ($teamid > 0) $showPlan_config['show_dnp_teams'] = 0;
			//$matches = $joomleague->getResultsPlan($round->matchcode, $teamid, $ordering);
			//$matches = $joomleague->getResults($round->matchcode);
			if (count($matches) > 0) {
			  $htmlHelper->show_matches($matches, $teams, $showPlan_config);
			}
			else echo '<tr><td style="text-align:center;font-weight:bold;">'._JL_RESULTS_NO_MATCHES_THIS_MATCHDAY.'</td></tr>';
			  $whatday++;
		?>
		</table>

		<?php
		if ($teamid == 0 || $whatday == count($rounds) && count($matches) > 0) { ?>
		<table width="100%" class="contentpaneopen">
			<tr>
				<td class="linktop" style="text-align:right">
				<?php
		  echo '<a href="'.str_replace('&', '&amp;', sefRelToAbs($_SERVER['REQUEST_URI'])).'#jl_top">'._JL_TOP.'</a>';
				?>
				</td>
		  </tr>
		</table>
		<!-- Main END -->
		<?php
		    }
		    else echo '<br />';
		  }

?>
<?php

if ($team_plan && $joomleague->teams_as_referees ) {
  ?>
  
  <br />
  <table width="100%" class="contentpaneopen">
	<tr>
		<td class="contentheading"><?php echo _JL_PLAN_REFERING;?><?php echo $teams[$team_plan]->name; ?></td>
	</tr>
  </table>
  <br />
  <table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <?php
    if (count($matches_refering) > 0) {
    $k=0;
    $lastdatum = '';
    $playing_teams = array();
    foreach($matches_refering as $v) {
      $match = new Match ($database);
      if (! $match->bind( get_object_vars($v)) ) {
        echo "error binding";
      }
      
      $showPlan_config['class'] = ($k == 0)? $showPlan_config['style_class1'] : $showPlan_config['style_class2'];
      $htmlHelper->newDayHeading($match->match_date, $olddate, $config);
  
      $htmlHelper->show_match_row($match, $teamsRefPlan, $favteams, $showPlan_config);
      $k = 1 - $k;
    }
  }
  //$htmlHelper->show_results($matches_refering, $showPlan_config, $mode);
  ?>
</table>
<?php
}
?>
<!-- Print Button START -->
<?php if ($showPlan_config['show_back_button'] > 0 OR $overall_config['show_back_button'] > 0) {;?>
<?php if ($showPlan_config['show_back_button'] == "1" OR $overall_config['show_back_button'] == "1") echo '<div align="left">'; else echo '<div align="right">';?>
<?php
$params = new mosParameters( '' );
$params->def( 'back_button', true );
$params->def( 'popup', false );
mosHTML::BackButton( $params );
  echo "</div>";
};?>
<!-- Print Button END -->
</div>